#include <iostream>
#include <vector>
#include <cctype>
#include <algorithm>
using namespace std;

//97.93 %
class Solution
{
  public:
	bool isPalindrome(string s)
	{
		int l = 0, r = s.size() - 1;
		transform(s.begin(), s.end(), s.begin(), ::toupper);
		while (l < r)
		{
			if (!isalnum(s[l]))
				l++;
			else if (!isalnum(s[r]))
				r--;
			else if (s[l] != s[r])
				return false;
			else
			{
				l++;
				r--;
			}
		}
		return true;
	}
};

int main()
{
	string s = "A man, a plan, a canal: Panama";
	cout << Solution().isPalindrome(s) << endl;
	return 0;
}
